<template>
  <div style="width: 100%">
    <el-select
      style="width: 100%"
      :model-value="val"
      :placeholder="option?.placeholder || '请选择'"
      @change="handleChange"
    >
      <el-option
        v-for="item in option?.options"
        :key="item.value"
        :label="item.label"
        :value="item.value"
      />
    </el-select>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';

export default defineComponent({
  name: 'Select',
  props: {
    modelValue: [String, Number],
    option: Object,
  },
  emits: ['update:modelValue'],
  // eslint-disable-next-line
  setup(props, { attrs, slots, emit, expose }) {
    // console.log('select', props.option);
    const val = ref(props.modelValue);

    const handleChange = (value: any) => {
      val.value = value;
      emit('update:modelValue', value);
    };

    return {
      // eslint-disable-next-line vue/no-dupe-keys
      option: props.option,
      val,
      handleChange,
    };
  },
});
</script>

<style scoped></style>
